/////////Download and install needed commands:
findit _gstd01

//////////Generate variables.
//////age.
rename ppage age
egen age01=std01(age)

//////gender.
recode ppgender (1=1) (2=0), generate(rsex)

//////black and latino dummy variables.
gen rblack=1 if ppethm==2
replace rblack=0 if ppethm~=2
gen rlat=1 if ppethm==4
replace rlat=0 if ppethm~=4

//////education.
recode ppeduc (1=8) (2=8) (3=8) (4=8) (5=8) (6=8) (7=8) (13=13) (14=13), ///
	generate(reduc)
egen reduc01=std01(reduc)

//////income.
rename ppincimp income
egen income01=std01(income)

//////Identity centrality.
gen ric1=(q4-1)/6 if q4>0
gen ric2=(q5-1)/6 if q5>0
egen rself=rmean(ric1 ric2)

//////dichotomized identity centrality.
gen rsdic=1 if rself>.60
replace rsdic=0 if rself<.60

//////Need for closure.
///scale.
gen nf6=q6 if q6>0
gen nf7=q7 if q7>0
gen nf8=q8 if q8>0
gen nf9=q9 if q9>0
gen nf10=q10 if q10>0
gen nf11=q11 if q11>0
gen nf12=q12 if q12>0
gen nf13=q13 if q13>0
gen nf14=q14 if q14>0
gen nf15=q15 if q15>0
gen nf16=q16 if q16>0
gen nf17=q17 if q17>0
gen nf18=q18 if q18>0
gen nf19=q19 if q19>0
egen nfscala=rmean(nf6-nf19)
gen nfscal=(nfscala-1)/5 

///Item parcels for SEM.
egen q601=std01(q6)
egen q701=std01(q7)
egen q801=std01(q8)
egen q901=std01(q9)
egen q1001=std01(q10)
egen q1101=std01(q11)
egen q1201=std01(q12)
egen q1301=std01(q13)
egen q1401=std01(q14)
egen q1501=std01(q15)
egen q1601=std01(q16)
egen q1701=std01(q17)
egen q1801=std01(q18)
egen q1901=std01(q19)
egen nfp1=rmean(q801 q1101 q1401 q1701 q901)
egen nfp2=rmean(q1201 q1601 q1801 q1901 q1001)
egen nfp3=rmean(q701 q1501 q601 q1301)

//////Political information.
gen kn1=0 if q20~=3
replace kn1=1 if q20==3
gen kn2=0 if q21~=2
replace kn2=1 if q21==2
gen kn3=0 if q22~=1
replace kn3=1 if q22==1
gen kn4=0 if q23~=2
replace kn4=1 if q23==2
gen kn5=0 if q24~=1
replace kn5=1 if q24==1
gen kn6=0 if q25~=1
replace kn6=1 if q25==1
gen kn7=0 if q26~=3
replace kn7=1 if q26==3
gen kn8=0 if q27~=1
replace kn8=1 if q27==1
egen knscal=rmean(kn1-kn8)

//////Symbolic ideology.
gen ideo=0 if q28==1 & q28a==1
replace ideo=1 if q28==1 & q28a==2
replace ideo=2 if q28>2 & q28c==1
replace ideo=3 if q28>2 & q28c==3
replace ideo=4 if q28>2 & q28c==2
replace ideo=5 if q28==2 & q28b==2
replace ideo=6 if q28==2 & q28b==1
gen idscal=ideo/6

//////Party identification.
gen pid=0 if q29==2 & q29b==1
replace pid=1 if q29==2 & q29b==2
replace pid=2 if (q29==3|q29==5) & q29c==3
replace pid=3 if (q29==3|q29==5) & q29c==2
replace pid=4 if (q29==3|q29==5) & q29c==1
replace pid=5 if q29==1 & q29a==2
replace pid=6 if q29==1 & q29a==1
gen pidscal=pid/6

//////Operational ideology.
///Code issue items:
gen issue1=0 if q30==3 & q30b==1
replace issue1=1 if q30==3 & q30b==2
replace issue1=2 if q30==2
replace issue1=3 if q30==1 & q30a==2
replace issue1=4 if q30==1 & q30a==1
gen issue1sc=issue1/4
gen issue2=0 if q31==1 & q31a==1
replace issue2=1 if q31==1 & q31a==2
replace issue2=2 if q31==2
replace issue2=3 if q31==3 & q31b==2
replace issue2=4 if q31==3 & q31b==1
gen issue2sc=issue2/4
gen issue3=0 if q32==1 & q32a==1
replace issue3=1 if q32==1 & q32a==2
replace issue3=2 if q32==2
replace issue3=3 if q32==3 & q32b==2
replace issue3=4 if q32==3 & q32b==1
gen issue3sc=issue3/4
gen issue4=0 if q33==1 & q33a==1
replace issue4=1 if q33==1 & q33a==2
replace issue4=2 if q33==2
replace issue4=3 if q33==3 & q33b==2
replace issue4=4 if q33==3 & q33b==1
gen issue4sc=issue4/4
gen issue5=0 if q34==1 & q34a==1
replace issue5=1 if q34==1 & q34a==2
replace issue5=2 if q34==2
replace issue5=3 if q34==3 & q34b==2
replace issue5=4 if q34==3 & q34b==1
gen issue5sc=issue5/4
gen issue6=0 if q35==1 & q35a==1
replace issue6=1 if q35==1 & q35a==2
replace issue6=2 if q35==2
replace issue6=3 if q35==3 & q35b==2
replace issue6=4 if q35==3 & q35b==1
gen issue6sc=issue6/4
gen issue7=0 if q36==1 & q36a==1
replace issue7=1 if q36==1 & q36a==2
replace issue7=2 if q36==2
replace issue7=3 if q36==3 & q36b==2
replace issue7=4 if q36==3 & q36b==1
gen issue7sc=issue7/4
gen issue8=0 if q37==1 & q37a==1
replace issue8=1 if q37==1 & q37a==2
replace issue8=2 if q37==2
replace issue8=3 if q37==3 & q37b==2
replace issue8=4 if q37==3 & q37b==1
gen issue8sc=issue8/4
///Compute factor score and recode 0-1:
factor issue1sc issue2sc issue3sc issue4sc issue5sc issue6sc ///
	issue7sc issue8sc, mine(1) ipf
predict fcompiss
egen fcompiss01=std01(fcompiss)

//////Obama evaluation.
gen robama=q38/100

//////McCain evaluation.
gen rmccain=q40/100

/////////ANALYSES IN MAIN PAPER.
//////Economic versus non-economic issues
///define variables.
egen econiss=rmean(issue1sc issue3sc)
egen noneiss=rmean(issue2sc issue4sc issue5sc issue6sc issue7sc issue8sc)
///economic.
reg econiss age01 rsex rblack rlat reduc01 income01 c.knscal c.rself ///
	c.nfscal c.nfscal#c.knscal c.nfscal#c.rself, robust
///all non-economic issues.
reg noneiss age01 rsex rblack rlat reduc01 income01 c.knscal c.rself ///
	c.nfscal c.nfscal#c.knscal c.nfscal#c.rself, robust

//////distinctiveness of symbolic ideology, operational ideology, and
//////party identification as predictors (plus variance inflation factors):
reg robama idscal fcompiss01 pidscal, robust
estat vif
reg rmccain idscal fcompiss01 pidscal, robust
estat vif

//////Correlations (Table 1).
pwcorr idscal pidscal fcompiss01 knscal rself nfscal, sig

//////set macros for simple slope-analyses.
quietly summarize rself
global m=r(mean)
global s=r(sd)
global rhi=$m+$s
global rlo=$m-$s
global rhih=$m+(.5*$s)
global rloh=$m-(.5*$s)
global step=(2*$s)/10

//////symbolic ideology (Table 2).
reg idscal age01 rsex rblack rlat reduc01 income01 c.knscal c.rself ///
	c.nfscal, robust
reg idscal age01 rsex rblack rlat reduc01 income01 c.knscal c.rself ///
	c.nfscal c.nfscal#c.knscal c.nfscal#c.rself, robust
///low and high simple slopes.
margins, dydx(nfscal) at(rself=($rlo $rhi))
///figure.
quietly margins, dydx(nfscal) at(rself=($rlo ($step) $rhi))
marginsplot, recast(line) recastci(rarea) plotop(lcolor(black)) ///
	ciopt(color(gs10)) ylabel(-.2 (.1) .8, gmin gmax nogex) ///
	xlabel($rlo ($s) $rhi) xtitle("Identity Centrality") ///
	ytitle("Simple Slope for NFC") title ("Symbolic Ideology", ///
	color(black)) graphr(c(white) lc(white)) plotr(lc(black)) ///
	aspectratio(1) saving (sig, replace)

//////party ID (Table 3).
reg pidscal age01 rsex rblack rlat reduc01 income01 c.knscal c.rself ///
	c.nfscal, robust
reg pidscal age01 rsex rblack rlat reduc01 income01 c.knscal c.rself ///
	c.nfscal c.nfscal#c.knscal c.nfscal#c.rself, robust
///low and high simple slopes.
margins, dydx(nfscal) at(rself=($rlo $rhi))
///figure.
quietly margins, dydx(nfscal) at(rself=($rlo ($step) $rhi))
marginsplot, recast(line) recastci(rarea) plotop(lcolor(black)) ///
	ciopt(color(gs10)) ylabel(-.2 (.1) .8, gmin gmax nogex) ///
	xlabel($rlo ($s) $rhi) xtitle("Identity Centrality") ///
	ytitle("Simple Slope for NFC") title ("Party ID", color(black)) ///
	graphr(c(white) lc(white)) plotr(lc(black)) ///
	aspectratio(1) saving (pidg, replace)
	
//////merged graphs: create Figure 1.
graph combine sig.gph pidg.gph, cols(2) altshrink ycommon ///
	ysize(3) saving(fig1, replace)

//////operational ideology (Table 4); create Figure 2.
reg fcompiss01 age01 rsex rblack rlat reduc01 income01 c.knscal c.rself ///
	c.nfscal, robust
reg fcompiss01 age01 rsex rblack rlat reduc01 income01 c.knscal c.rself ///
	c.nfscal c.nfscal#c.knscal c.nfscal#c.rself, robust
///low and high simple slopes.
margins, dydx(nfscal) at(rself=($rlo $rhi))
///figure.
quietly margins, dydx(nfscal) at(rself=($rlo ($step) $rhi))
marginsplot, recast(line) recastci(rarea) plotop(lcolor(black)) ///
	ciopt(color(gs10)) ylabel(-.2 (.1) .8, gmin gmax nogex) ///
	xlabel($rlo ($s) $rhi) xtitle("Identity Centrality") ///
	ytitle("Simple Slope for NFC") ///
	title("Operational Ideology", color(black)) graphr(c(white) ///
	lc(white)) plotr(lc(black)) aspectratio(1) saving (fig2, replace)

//////Multigroup SEM models: All estimated in Mplus.
//////Variable names in Mplus files are the same as
//////those defined above.	
	
/////////ANALYSES IN SOM-R.
//////3. Mediation Moderation Analysis: Conditional-Process Approach
//////Note: .7074785 is the mean value for political information (knscal).
capture program drop bootm7
program bootm7, rclass
	quietly reg idscal age01 rsex rblack rlat reduc01 income01 c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself
	quietly est store si1
	quietly reg pidscal age01 rsex rblack rlat reduc01 income01 c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself
	quietly est store si2
	quietly reg fcompiss01 age01 rsex rblack rlat reduc01 income01 c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself c.idscal c.idscal#c.knscal c.idscal#c.rself c.pidscal c.pidscal#c.knscal c.pidscal#c.rself
	quietly est store oi
	quietly suest si1 si2 oi, vce(robust)
	return scalar iie1 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($rlo)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($rlo)*_b[oi_mean:c.idscal#c.rself])
	return scalar iie2 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($rloh)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($rloh)*_b[oi_mean:c.idscal#c.rself])
	return scalar iie3 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($m)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($m)*_b[oi_mean:c.idscal#c.rself])
	return scalar iie4 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($rhih)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($rhih)*_b[oi_mean:c.idscal#c.rself])
	return scalar iie5 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($rhi)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($rhi)*_b[oi_mean:c.idscal#c.rself])
	return scalar pie1 = ((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($rlo)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($rlo)*_b[oi_mean:c.pidscal#c.rself])
	return scalar pie2 = ((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($rloh)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($rloh)*_b[oi_mean:c.pidscal#c.rself])
	return scalar pie3 = ((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($m)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($m)*_b[oi_mean:c.pidscal#c.rself])
	return scalar pie4 = ((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($rhih)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($rhih)*_b[oi_mean:c.pidscal#c.rself])
	return scalar pie5 = ((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($rhi)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($rhi)*_b[oi_mean:c.pidscal#c.rself])
	return scalar tie1 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($rlo)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($rlo)*_b[oi_mean:c.idscal#c.rself]) + ///
	((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($rlo)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($rlo)*_b[oi_mean:c.pidscal#c.rself])
	return scalar tie2 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($rloh)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($rloh)*_b[oi_mean:c.idscal#c.rself]) + ///
	((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($rloh)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($rloh)*_b[oi_mean:c.pidscal#c.rself])
	return scalar tie3 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($m)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($m)*_b[oi_mean:c.idscal#c.rself]) + ///
	((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($m)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($m)*_b[oi_mean:c.pidscal#c.rself])
	return scalar tie4 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($rhih)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($rhih)*_b[oi_mean:c.idscal#c.rself]) + ///
	((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($rhih)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($rhih)*_b[oi_mean:c.pidscal#c.rself])
	return scalar tie5 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($rhi)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($rhi)*_b[oi_mean:c.idscal#c.rself]) + /// 
	((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($rhi)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($rhi)*_b[oi_mean:c.pidscal#c.rself])
end
bootstrap r(iie1) r(iie2) r(iie3) r(iie4) r(iie5) r(pie1) r(pie2) r(pie3) r(pie4) r(pie5) r(tie1) r(tie2) r(tie3) r(tie4) r(tie5), reps(1000) nodots: bootm7
estat boot, bc percentile	

//////Note that the bootstrap produces slightly different CIs on each run. 
//////The above will produce slightly different CIs from our original run, shown here:
------------------------------------------------------------------------------
             |    Observed               Bootstrap
             |       Coef.       Bias    Std. Err.  [95% Conf. Interval]
-------------+----------------------------------------------------------------
       _bs_1 |   .02384837   .0011793   .02149651   -.0179372   .0669563   (P)
             |                                        -.01957   .0623297  (BC)
       _bs_2 |   .05227315   .0007528   .01845809     .017101   .0888957   (P)
             |                                       .0170103   .0888722  (BC)
       _bs_3 |   .08272547   .0002342   .01823165     .048646   .1198555   (P)
             |                                        .050492   .1229387  (BC)
       _bs_4 |   .11520535  -.0003764    .0218657    .0748223   .1614543   (P)
             |                                       .0766412   .1629001  (BC)
       _bs_5 |   .14971278   -.001079   .02891956    .0942384   .2056371   (P)
             |                                       .0987335   .2145561  (BC)
       _bs_6 |   .01536325   .0002302   .01362662   -.0113877   .0424196   (P)
             |                                      -.0103038   .0439658  (BC)
       _bs_7 |   .03208808   .0001178   .01232534    .0085622    .056252   (P)
             |                                       .0099419   .0574838  (BC)
       _bs_8 |   .05152921   .0000987   .01257735     .029032    .076296   (P)
             |                                       .0298033   .0781267  (BC)
       _bs_9 |   .07368666    .000173   .01581481     .045273   .1061032   (P)
             |                                       .0460425   .1080091  (BC)
      _bs_10 |   .09856041   .0003405   .02222907    .0585271   .1442939   (P)
             |                                       .0593795   .1444027  (BC)
      _bs_11 |   .03921162   .0014096   .03130419   -.0225781    .101578   (P)
             |                                      -.0250701   .0988612  (BC)
      _bs_12 |   .08436122   .0008706   .02715573    .0326882   .1403302   (P)
             |                                       .0321721   .1368676  (BC)
      _bs_13 |   .13425468   .0003329   .02705159    .0830442   .1903043   (P)
             |                                        .082726   .1896878  (BC)
      _bs_14 |   .18889201  -.0002034    .0326046    .1275359   .2547915   (P)
             |                                       .1289284   .2556821  (BC)
      _bs_15 |   .24827319  -.0007385   .04303969    .1642356   .3308755   (P)
             |                                       .1684956   .3339357  (BC)
------------------------------------------------------------------------------
(P)    percentile confidence interval
(BC)   bias-corrected confidence interval

//////4. Reversed Mediation Models.
///Via symbolic ideology:
///Note: .7074785 is the mean value for political information (knscal).
reg fcompiss01 age01 rsex rblack rlat reduc01 income01 c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself
est store roi
reg idscal age01 rsex rblack rlat reduc01 income01 c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself c.fcompiss01 c.fcompiss01#c.knscal c.fcompiss01#c.rself
est store rsi
suest roi rsi, vce(robust)
capture program drop bootm8
program bootm8, rclass
	quietly reg fcompiss01 age01 rsex rblack rlat reduc01 income01 c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself
	quietly est store roi
	quietly reg idscal age01 rsex rblack rlat reduc01 income01 c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself c.fcompiss01 c.fcompiss01#c.knscal c.fcompiss01#c.rself
	quietly est store rsi
	quietly suest roi rsi, vce(robust)
	return scalar ie1 = ((_b[roi_mean:nfscal]+(.7074785)*_b[roi_mean:c.nfscal#c.knscal])+($rlo)*_b[roi_mean:c.nfscal#c.rself])*((_b[rsi_mean:fcompiss01]+(.7074785)*_b[rsi_mean:c.fcompiss01#c.knscal])+($rlo)*_b[rsi_mean:c.fcompiss01#c.rself])
	return scalar ie2 = ((_b[roi_mean:nfscal]+(.7074785)*_b[roi_mean:c.nfscal#c.knscal])+($rloh)*_b[roi_mean:c.nfscal#c.rself])*((_b[rsi_mean:fcompiss01]+(.7074785)*_b[rsi_mean:c.fcompiss01#c.knscal])+($rloh)*_b[rsi_mean:c.fcompiss01#c.rself])
	return scalar ie3 = ((_b[roi_mean:nfscal]+(.7074785)*_b[roi_mean:c.nfscal#c.knscal])+($m)*_b[roi_mean:c.nfscal#c.rself])*((_b[rsi_mean:fcompiss01]+(.7074785)*_b[rsi_mean:c.fcompiss01#c.knscal])+($m)*_b[rsi_mean:c.fcompiss01#c.rself])
	return scalar ie4 = ((_b[roi_mean:nfscal]+(.7074785)*_b[roi_mean:c.nfscal#c.knscal])+($rhih)*_b[roi_mean:c.nfscal#c.rself])*((_b[rsi_mean:fcompiss01]+(.7074785)*_b[rsi_mean:c.fcompiss01#c.knscal])+($rhih)*_b[rsi_mean:c.fcompiss01#c.rself])
	return scalar ie5 = ((_b[roi_mean:nfscal]+(.7074785)*_b[roi_mean:c.nfscal#c.knscal])+($rhi)*_b[roi_mean:c.nfscal#c.rself])*((_b[rsi_mean:fcompiss01]+(.7074785)*_b[rsi_mean:c.fcompiss01#c.knscal])+($rhi)*_b[rsi_mean:c.fcompiss01#c.rself])
end
bootstrap r(ie1) r(ie2) r(ie3) r(ie4) r(ie5), reps(1000) nodots: bootm8
estat boot, bc percentile
//////Note that the bootstrap produces slightly different CIs on each run. 
//////The above will produce slightly different CIs from our original run.

///Via party identification:
///Note: .7074785 is the mean value for political information (knscal).
reg fcompiss01 age01 rsex rblack rlat reduc01 income01 c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself
est store roi
reg pidscal age01 rsex rblack rlat reduc01 income01 c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself c.fcompiss01 c.fcompiss01#c.knscal c.fcompiss01#c.rself
est store rpi
suest roi rpi, vce(robust)
capture program drop bootm9
program bootm9, rclass
	quietly reg fcompiss01 age01 rsex rblack rlat reduc01 income01 c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself
	quietly est store roi
	quietly reg pidscal age01 rsex rblack rlat reduc01 income01 c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself c.fcompiss01 c.fcompiss01#c.knscal c.fcompiss01#c.rself
	quietly est store rsi
	quietly suest roi rsi, vce(robust)
	return scalar ie1 = ((_b[roi_mean:nfscal]+(.7074785)*_b[roi_mean:c.nfscal#c.knscal])+($rlo)*_b[roi_mean:c.nfscal#c.rself])*((_b[rsi_mean:fcompiss01]+(.7074785)*_b[rsi_mean:c.fcompiss01#c.knscal])+($rlo)*_b[rsi_mean:c.fcompiss01#c.rself])
	return scalar ie2 = ((_b[roi_mean:nfscal]+(.7074785)*_b[roi_mean:c.nfscal#c.knscal])+($rloh)*_b[roi_mean:c.nfscal#c.rself])*((_b[rsi_mean:fcompiss01]+(.7074785)*_b[rsi_mean:c.fcompiss01#c.knscal])+($rloh)*_b[rsi_mean:c.fcompiss01#c.rself])
	return scalar ie3 = ((_b[roi_mean:nfscal]+(.7074785)*_b[roi_mean:c.nfscal#c.knscal])+($m)*_b[roi_mean:c.nfscal#c.rself])*((_b[rsi_mean:fcompiss01]+(.7074785)*_b[rsi_mean:c.fcompiss01#c.knscal])+($m)*_b[rsi_mean:c.fcompiss01#c.rself])
	return scalar ie4 = ((_b[roi_mean:nfscal]+(.7074785)*_b[roi_mean:c.nfscal#c.knscal])+($rhih)*_b[roi_mean:c.nfscal#c.rself])*((_b[rsi_mean:fcompiss01]+(.7074785)*_b[rsi_mean:c.fcompiss01#c.knscal])+($rhih)*_b[rsi_mean:c.fcompiss01#c.rself])
	return scalar ie5 = ((_b[roi_mean:nfscal]+(.7074785)*_b[roi_mean:c.nfscal#c.knscal])+($rhi)*_b[roi_mean:c.nfscal#c.rself])*((_b[rsi_mean:fcompiss01]+(.7074785)*_b[rsi_mean:c.fcompiss01#c.knscal])+($rhi)*_b[rsi_mean:c.fcompiss01#c.rself])
end
bootstrap r(ie1) r(ie2) r(ie3) r(ie4) r(ie5), reps(1000) nodots: bootm9
estat boot, bc percentile
//////Note that the bootstrap produces slightly different CIs on each run. 
//////The above will produce slightly different CIs from our original run.

//////5. Tests of Hypotheses Without Demographics.
///symbolic ideology.
reg idscal c.knscal c.rself c.nfscal, robust
reg idscal c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself, robust
margins, dydx(nfscal) at(rself=($rlo $rhi))
///party ID.
reg pidscal c.knscal c.rself c.nfscal, robust
reg pidscal c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself, robust
margins, dydx(nfscal) at(rself=($rlo $rhi))	
///operational ideology
reg fcompiss01 c.knscal c.rself c.nfscal, robust
reg fcompiss01 c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself, robust
margins, dydx(nfscal) at(rself=($rlo $rhi))
///multiple mediators, no demographics.
///Note: .7074785 is the mean value for political information (knscal).
capture program drop bootm10
program bootm10, rclass
	quietly reg idscal c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself
	quietly est store si1
	quietly reg pidscal c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself
	quietly est store si2
	quietly reg fcompiss01 c.knscal c.rself c.nfscal c.nfscal#c.knscal c.nfscal#c.rself c.idscal c.idscal#c.knscal c.idscal#c.rself c.pidscal c.pidscal#c.knscal c.pidscal#c.rself
	quietly est store oi
	quietly suest si1 si2 oi, vce(robust)
	return scalar iie1 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($rlo)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($rlo)*_b[oi_mean:c.idscal#c.rself])
	return scalar iie2 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($rloh)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($rloh)*_b[oi_mean:c.idscal#c.rself])
	return scalar iie3 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($m)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($m)*_b[oi_mean:c.idscal#c.rself])
	return scalar iie4 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($rhih)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($rhih)*_b[oi_mean:c.idscal#c.rself])
	return scalar iie5 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($rhi)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($rhi)*_b[oi_mean:c.idscal#c.rself])
	return scalar pie1 = ((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($rlo)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($rlo)*_b[oi_mean:c.pidscal#c.rself])
	return scalar pie2 = ((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($rloh)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($rloh)*_b[oi_mean:c.pidscal#c.rself])
	return scalar pie3 = ((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($m)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($m)*_b[oi_mean:c.pidscal#c.rself])
	return scalar pie4 = ((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($rhih)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($rhih)*_b[oi_mean:c.pidscal#c.rself])
	return scalar pie5 = ((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($rhi)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($rhi)*_b[oi_mean:c.pidscal#c.rself])
	return scalar tie1 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($rlo)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($rlo)*_b[oi_mean:c.idscal#c.rself]) + ///
	((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($rlo)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($rlo)*_b[oi_mean:c.pidscal#c.rself])
	return scalar tie2 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($rloh)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($rloh)*_b[oi_mean:c.idscal#c.rself]) + ///
	((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($rloh)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($rloh)*_b[oi_mean:c.pidscal#c.rself])
	return scalar tie3 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($m)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($m)*_b[oi_mean:c.idscal#c.rself]) + ///
	((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($m)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($m)*_b[oi_mean:c.pidscal#c.rself])
	return scalar tie4 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($rhih)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($rhih)*_b[oi_mean:c.idscal#c.rself]) + ///
	((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($rhih)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($rhih)*_b[oi_mean:c.pidscal#c.rself])
	return scalar tie5 = ((_b[si1_mean:nfscal]+(.7074785)*_b[si1_mean:c.nfscal#c.knscal])+($rhi)*_b[si1_mean:c.nfscal#c.rself])*((_b[oi_mean:idscal]+(.7074785)*_b[oi_mean:c.idscal#c.knscal])+($rhi)*_b[oi_mean:c.idscal#c.rself]) + /// 
	((_b[si2_mean:nfscal]+(.7074785)*_b[si2_mean:c.nfscal#c.knscal])+($rhi)*_b[si2_mean:c.nfscal#c.rself])*((_b[oi_mean:pidscal]+(.7074785)*_b[oi_mean:c.pidscal#c.knscal])+($rhi)*_b[oi_mean:c.pidscal#c.rself])
end
bootstrap r(iie1) r(iie2) r(iie3) r(iie4) r(iie5) r(pie1) r(pie2) r(pie3) r(pie4) r(pie5) r(tie1) r(tie2) r(tie3) r(tie4) r(tie5), reps(1000) nodots: bootm10
estat boot, bc percentile
//////Note that the bootstrap produces slightly different CIs on each run. 
//////The above will produce slightly different CIs from our original run.
